// Drummer
// by Andrea Bianchi
// andreabianchi.alsoplantsfly.com

/*
 Copyright (C) 2009, Andrea Bianchi
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  021
 10-1301, USA.
*/


#ifndef __NETWORK_MANAGER__H__
#define __NETWORK_MANAGER__H__

#include "global.h"
#include <string>
#define BUFFER_SIZE 16

namespace DS
{

	class NetworkManager 
	{
	public:
		static NetworkManager* getInstance();
		
		bool initConnection();
		bool disconnect();

		void sendMessage (std::string message);
		void sendMessage (DrumPart instrument);
		void sendMessage (DrumPart instrument, u8 velocity);

	private:
		NetworkManager(): firstTime_(true){}
		~NetworkManager(){}

		void initKeyboard();
		void closeKeyboard();
		std::string getKeyboardInput(char* message);

		bool isValidIp (std::string ip);
		bool isNumber (std::string val);
		bool isNumber (char val);
	
		int port_, socket_;
		std::string serverName_;
		bool firstTime_;
	};
}

#endif __NETWORK_MANAGER__H__